package com.ncp.servlet.bbs;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ncp.model.biz.bbs.ArticleProcess;
import com.ncp.model.biz.bbs.ReplyProcess;



public class AdminServlet extends HttpServlet {


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		int id=Integer.parseInt(request.getParameter("id"));
		String type=request.getParameter("type");
		if(type.equals("article")){
			if(new ArticleProcess().deleteArticle(id)){
				response.sendRedirect("pages/admin/bbs/showarticle.jsp");
			}
		}else{
			int rootid=Integer.parseInt(request.getParameter("rootid"));
			if(new ReplyProcess().deleteReply(id)){
				response.sendRedirect("AdminReplyServlet?id="+rootid);
			}
		}
	}

}
